﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PI_CS_Tools;

namespace  PI_CS_Library.Virtual_Network_Information_Model
{
    public class NetworkConnection
    {
        Identification _id;
        Dictionary<int, LinkConnection> _linkConnectionsList;
        Dictionary<int, IMatrixConnection> _matrixConnectionsList;
        int _capacity;
        NwTTP _srcPoint;
        NwTTP _sinkPoint;

        public NetworkConnection(NwTTP _srcPoint, NwTTP _sinkPoint, int _connId, int _capacity)
        {
            _id = new Identification(_connId, "Network Connection: Source: "+_srcPoint.ToString() + " Sink: " + _sinkPoint.ToString());
            this._srcPoint = _srcPoint;
            this._sinkPoint = _sinkPoint;
            this._capacity = _capacity;
            _linkConnectionsList = new Dictionary<int, LinkConnection>();
            _matrixConnectionsList = new Dictionary<int, IMatrixConnection>();
        }

        public NetworkConnection(NwTTP _srcPoint, NwTTP _sinkPoint,
            Dictionary<int, LinkConnection> _linkConnectionsList, Dictionary<int, IMatrixConnection> _matrixConnectionsList, int _capacity)
        {
            _id = new Identification("Network Connection: Source: " + _srcPoint.ToString() + " Sink: " + _sinkPoint.ToString());
            this._srcPoint = _srcPoint;
            this._sinkPoint = _sinkPoint;
            this._capacity = _capacity;
            this._linkConnectionsList = _linkConnectionsList;
            this._matrixConnectionsList = _matrixConnectionsList;
        }

        public void AddMatrixConnection<SrcPointType, SinkPointType>(MatrixConnection<SrcPointType, SinkPointType> item)
        {
            _matrixConnectionsList[item.Id.Number] = item;

        }

        public MatrixConnection<SrcPointType, SinkPointType> GetMatrixConnection<SrcPointType, SinkPointType>(int _id)
        {
            return _matrixConnectionsList[_id] as MatrixConnection<SrcPointType, SinkPointType>;
        }

        public Identification Id
        {
            get { return _id; }
            set { _id = value; }
        }

        public NwTTP SrcPoint
        {
            get { return _srcPoint; }
            set { _srcPoint = value; }
        }

        public NwTTP SinkPoint
        {
            get { return _sinkPoint; }
            set { _sinkPoint = value; }
        }

        public int Capacity
        {
            get { return _capacity; }
            set { _capacity = value; }
        }

        public Dictionary<int, IMatrixConnection> MatrixConnectionsList
        {
            get { return _matrixConnectionsList; }
            set { _matrixConnectionsList = value; }
        }

        public Dictionary<int, LinkConnection> LinkConnectionsList
        {
            get { return _linkConnectionsList; }
            set { _linkConnectionsList = value; }
        }

        public override string ToString()
        {
            return _id.ToString();
        }

    }

}
